package cn.itsource.org.service.impl;

import cn.itsource.basic.util.PageList;
import cn.itsource.org.domain.Department;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.query.EmployeeQuery;
import cn.itsource.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    EmployeeMapper employeeMapper;

    @Override
    public List<Employee> queryAll() {
        return employeeMapper.loadAll();
    }

    @Override
    public PageList<Employee> queryPage(EmployeeQuery query) {
        Integer total = employeeMapper.queryCount(query);
        List<Employee> rows = employeeMapper.queryData(query);
        return new PageList<Employee>(total,rows);
    }

    @Override
    public void delete(Long id) {
        employeeMapper.remove(id);
    }

    @Override
    public void deleteByIds(Long[] ids) {
        employeeMapper.deleteByIds(ids);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public void add(Employee employee) {
        employeeMapper.add(employee);
    }
}
